package com.jyw.common.utils;

/**
 * @author Created by ZhangCheng on 2023/11/29 (时间格式化)
 */
public class TimeFormatUtil {

    private static final long ONE_MINUTE_SECONDS = 60;

    private static final int NIGHT_END_HOUR = 24;

    /**
     * 将秒数数格式化为天时分
     *
     * @param minutesParam
     * @return
     */
    public static String formatMinutes(long minutesParam) {
        String result;
        long days = minutesParam / ( ONE_MINUTE_SECONDS * ONE_MINUTE_SECONDS * NIGHT_END_HOUR);
        long hours = (minutesParam % ( ONE_MINUTE_SECONDS * ONE_MINUTE_SECONDS * NIGHT_END_HOUR)) / (ONE_MINUTE_SECONDS * ONE_MINUTE_SECONDS);
        long minutes = (minutesParam % ( ONE_MINUTE_SECONDS * ONE_MINUTE_SECONDS)) /ONE_MINUTE_SECONDS;
        if(days > 0) {
            result = days + "天" + hours + "小时" + minutes + "分钟";
        } else if(hours > 0) {
            result = hours + "小时" + minutes + "分钟";
        } else{
            result = minutes + "分钟";
        }
        return result;
    }
}
